import 'package:flutter/material.dart';
import 'package:keep_accounts/entity/work_record.dart';
import 'package:objectbox/objectbox.dart';

@Entity()
class Period {
  @Id()
  int id = 0;

  final record = ToOne<WorkRecord>();

  String? dayPeriod;
  int? startTime;
  int? endTime;

  Duration get duration {
    if(startTime == null || endTime == null) {
      return Duration.zero;
    }
    return DateTime.fromMillisecondsSinceEpoch(endTime!).difference(DateTime.fromMillisecondsSinceEpoch(startTime!));
  }
}